package br.com.naybee.framework.client.componente.gwt.web;

import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.LabelElement;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.Widget;

public class Label extends ComplexPanel implements HasClickHandlers {
	private LabelElement createLabel = DOM.createLabel().cast();

	public Label() {
		setElement(createLabel);
	}

	public void add(Widget w) {
		Element element = this.createLabel;
		this.add(w, element);
	}

	public void setText(String text) {
		createLabel.setInnerText(text);
	}

	public String getText() {
		return createLabel.getInnerText();
	}

	public void setClassName(String className) {
		createLabel.setClassName(className);
	}

	public String getClassName() {
		return createLabel.getClassName();
	}

	public void setFor(String forevent) {
		createLabel.setAttribute("for", forevent);
	}

	public HandlerRegistration addClickHandler(ClickHandler handler) {
		return addDomHandler(handler, ClickEvent.getType());
	}

}
